<template>
	<view class='book-grid'>
		<view class="book-item" v-for="(v,k) in booklist" :key="k" @click="goIntroduction(v)">
			<view class="book-img">
				<image :src="v.cover_vertical" mode="widthFix" lazy-load="true"></image>
			</view>
			<view class="book-content">
				<view class="book-title">
					{{v.name}}
				</view>
				<view class="book-desc">
					{{v.intro}}
				</view>
<!-- 				<view class="book-tags">
					<text class="tag" v-for="(tag,idx) in v.tags" :key="idx">
						{{tag}}
					</text>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "BookListGrid",
		props: {
			booklist: {
				type: Array,
				default: () => []
			}
		},
		methods: {
			goIntroduction(v) {
				uni.navigateTo({
					url: `/pages/play/index?drama_id=1&episode_index=1`
				})
			}
		},
	}
</script>

<style lang="less" scope>
	.book-grid {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
		// padding: 0 20rpx;
		margin-top: -20rpx;

		.book-item {
			width: calc(33.333% - 13.33rpx);
			margin-bottom: 30rpx;
			margin-left: 12rpx;
			display: flex;
			flex-direction: column;
			
			.book-img {
				width: 100%;
				border-radius: 16rpx;
				overflow: hidden;
				border: 4px solid #d6d6d6;

				image {
					display: block;
					width: 100%;
					height: auto;
				}
			}

			.book-content {
				width: 100%;
				margin-top: 12rpx;

				.book-title {
					font-size: 24rpx;
					font-weight: 500;
					color: #333333;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1;
					margin-bottom: 6rpx;
				}

				.book-desc {
					font-size: 20rpx;
					color: #717171;
					line-height: 28rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					margin-bottom: 8rpx;
				}

				.book-tags {
					display: flex;
					flex-wrap: wrap;
					gap: 6rpx;

					.tag {
						height: 28rpx;
						padding: 0 8rpx;
						border-radius: 6rpx;
						font-size: 18rpx;
						line-height: 28rpx;
						text-align: center;
					}

					.tag:nth-child(odd) {
						background: #E0EFEF;
						color: #77A7A2;
					}

					.tag:nth-child(even) {
						background: #FFE0DD;
						color: #F38C93;
					}
				}
			}
		}
	}
</style>

